package com.zl.cms.model;


import javax.persistence.*;

/**
 * User: zl
 * email:c3tc3tc3t@126.com
 * Date: 14-1-13
 * Time: 下午4:50
 * 角色对象用来对应可以访问的功能,只定义管理员，文章发布人员，审核人员
 */

//@Entity
//@Table(name="t_role")
public class Role {
	/**
	 * 角色id
	 */
	private int id;
	/**
	 * 角色名称
	 */
	private  String name;
	/**
	 * 角色编号，枚举类型
	 */
	private RoleType roleType;

	public Role() {
	}

	public Role(int id, String name, RoleType roleType) {
		this.id = id;
		this.name = name;
		this.roleType = roleType;
	}

	public Role(String name, RoleType roleType) {
		this.name = name;
		this.roleType = roleType;
	}
	//@Id
	//@GeneratedValue(strategy = GenerationType.IDENTITY)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	//@Enumerated(EnumType.ORDINAL)
	//@Column(name="role_type")
	public RoleType getRoleType() {
		return roleType;
	}

	public void setRoleType(RoleType roleType) {
		this.roleType = roleType;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		Role role = (Role) o;

		if (id != role.getId()) return false;
		if (!name.equals(role.getName())) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = id;
		result = 31 * result + name.hashCode();
		return result;
	}

	@Override
	public String toString() {
		return "Role{" +
				"id=" + id +
				", name='" + name + '\'' +
				", roleType=" + roleType +
				'}';
	}
}
